/****************************************
 * 2018 - 2021 版权所有 CopyRight(c) 快程乐码信息科技有限公司所有, 未经授权，不得复制、转发
 */

package com.yuyan;

import com.yuyan.domain.Clazz;
import com.yuyan.domain.MoreEntity;
import com.yuyan.domain.Name;
import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MapperFactory;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/*****************
 *
 * @author tanj
 * @date 2020/7/10 12:10
 * @version v1.0
 * @description
 *
 */
@SpringBootTest
public class NameAndClazz {
    @Autowired
    private MapperFactory mapperFactory;

    /***
     * 多个实体类转换成一个实体类
     */
    @Test
    public void test(){
        //获取MapperFacade映射器
        MapperFacade mapperFacade = mapperFactory.getMapperFacade();

        Name name = new Name("zhangsan",25);
        Clazz clazz = new Clazz("123456", "android");

        MoreEntity moreEntity = new MoreEntity();
        //通过map映射
        mapperFacade.map(name,moreEntity);
        mapperFacade.map(clazz,moreEntity);

        System.out.println(clazz);
        System.out.println(moreEntity);
    }
}
